package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.domain.ImcFundOrderExpression;
import com.yxinsur.imc.business.form.FundBrokerForm;
import com.yxinsur.imc.business.form.FundOrderForm;
import com.yxinsur.imc.business.service.IImcFundOrderExpressionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 保单口径（暨口径达式配置）Controller
 *
 * @author imc
 * @date 2021-10-29
 */
@Api(value="基本法配置保单口径接口",tags={"基本法配置保单口径接口"})
@RestController
@RequestMapping("/business/fund/order/expression")
public class ImcFundOrderExpressionController extends BaseController {
    @Autowired
    private IImcFundOrderExpressionService imcFundOrderExpressionService;

    /**
     * 查询保单口径（暨口径达式配置）列表
     */
    @PreAuthorize("@ss.hasPermi('system:expression:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImcFundOrderExpression imcFundOrderExpression) {
        startPage();
        List<ImcFundOrderExpression> list = imcFundOrderExpressionService.selectImcFundOrderExpressionList(imcFundOrderExpression);
        return getDataTable(list);
    }

    /**
     * 导出保单口径（暨口径达式配置）列表
     */
    @PreAuthorize("@ss.hasPermi('system:expression:export')")
    @Log(title = "保单口径（暨口径达式配置）", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImcFundOrderExpression imcFundOrderExpression) {
        List<ImcFundOrderExpression> list = imcFundOrderExpressionService.selectImcFundOrderExpressionList(imcFundOrderExpression);
        ExcelUtil<ImcFundOrderExpression> util = new ExcelUtil<ImcFundOrderExpression>(ImcFundOrderExpression.class);
        return util.exportExcel(list, "expression");
    }

    /**
     * 获取保单口径（暨口径达式配置）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:expression:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(imcFundOrderExpressionService.selectImcFundOrderExpressionById(id));
    }

    /**
     * 获取基本法的保单口径（暨口径达式配置）详细信息
     */
    @ApiOperation("获取基本法的保单口径（暨口径达式配置）详细信息")
    @GetMapping(value = "getInfo/first/{fundId}")
    public AjaxResult getInfoFirst(@PathVariable("fundId") Long fundId) {
        return AjaxResult.success(imcFundOrderExpressionService.selectImcFundOrderExpressionByFundId(fundId,"A"));
    }

    /**
     * 获取基本法的保单口径（暨口径达式配置）详细信息
     */
    @ApiOperation("获取基本法的保单口径（暨口径达式配置）详细信息")
    @GetMapping(value = "getInfo/renewal/{fundId}")
    public AjaxResult getInfoRenewal(@PathVariable("fundId") Long fundId) {
        return AjaxResult.success(imcFundOrderExpressionService.selectImcFundOrderExpressionByFundId(fundId,"B"));
    }

    /**
     * 新增保单口径（暨口径达式配置）
     */
    @ApiOperation("新增保单口径（暨口径达式配置）")
    @Log(title = "新增保单口径（暨口径达式配置）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FundOrderForm fundOrderForm) {
        return toAjax(imcFundOrderExpressionService.insertImcFundOrderExpression(fundOrderForm));
    }

    /**
     * 修改保单口径（暨口径达式配置）
     */
    @ApiOperation("修改保单口径（暨口径达式配置）")
    @Log(title = "修改保单口径（暨口径达式配置）", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FundOrderForm fundOrderForm) {
        return toAjax(imcFundOrderExpressionService.updateImcFundOrderExpression(fundOrderForm));
    }

    /**
     * 生成&检测口径
     */
    @ApiOperation("保单口径-生成&检测口径")
    @Log(title = "保单口径-生成&检测口径", businessType = BusinessType.INSERT)
    @PutMapping("/check")
    public AjaxResult checkExpenseExpression(@RequestBody FundOrderForm fundOrderForm) {
        return this.imcFundOrderExpressionService.checkExpenseExpression(fundOrderForm);
    }
}
